package com.ddstation.app.appeal.service;

import com.ddstation.app.appeal.model.AppAppealModel;
import com.ddstation.crud.mapper.DtInvsIllegalAppealMapper;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service @Lazy
public class AppAppealServiceImpl implements AppAppealService {

	@Inject private DtInvsIllegalAppealMapper dtInvsIllegalAppealMapper;

	@Override
	public List<AppAppealModel> queryAppealList(String institutionId,Integer appealSt, Integer type) {
		Date startDate = null;
		Calendar cale = Calendar.getInstance();
		cale.setTime(new Date());
		switch (type) {
			case 0:
			case 1:	//近一周
				cale.add(Calendar.DAY_OF_MONTH, -6);
				startDate = cale.getTime();
				break;
			case 2:	//近一月
				cale.add(Calendar.MONTH, -1);
				startDate = cale.getTime();
				break;
			case 3:	//近一年
				cale.add(Calendar.YEAR, -1);
				startDate = cale.getTime();
				break;
		}

		return dtInvsIllegalAppealMapper.queryAppealList(institutionId,appealSt,startDate);
	}
}
